import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace TeamMemberApi {
  /** 团队成员信息 */
  export interface TeamMember {
    id?: number;
    // TODO: 添加字段
  }

  /** 团队成员分页查询参数 */
  export interface TeamMemberPageReqVO extends PageParam {
    createTime?: string[];
    // TODO: 添加查询条件字段
  }
}

/** 查询团队成员分页 */
export function getTeamMemberPage(params: TeamMemberApi.TeamMemberPageReqVO) {
  return requestClient.get<PageResult<TeamMemberApi.TeamMember>>(
    '/cmt/team-member/page',
    { params },
  );
}

/** 查询团队成员详情 */
export function getTeamMember(id: number) {
  return requestClient.get<TeamMemberApi.TeamMember>(
    `/cmt/team-member/get?id=${id}`,
  );
}

/** 新增团队成员 */
export function createTeamMember(data: TeamMemberApi.TeamMember) {
  return requestClient.post('/cmt/team-member/create', data);
}

/** 修改团队成员 */
export function updateTeamMember(data: TeamMemberApi.TeamMember) {
  return requestClient.put('/cmt/team-member/update', data);
}

/** 删除团队成员 */
export function deleteTeamMember(id: number) {
  return requestClient.delete(`/cmt/team-member/delete?id=${id}`);
}

/** 批量删除团队成员 */
export function deleteTeamMemberList(ids: number[]) {
  return requestClient.delete(
    `/cmt/team-member/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出团队成员 */
export function exportTeamMember(params: any) {
  return requestClient.download('/cmt/team-member/export-excel', { params });
}
